package com.xinlong.controller;

import com.xinlong.entity.Vehicle;
import com.xinlong.service.IVehiceService;
import com.xinlong.service.impl.VehiceServiceimpl;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/vehice")
public class Vehicecontroller {

    @Autowired
    IVehiceService vehiceServiceimpl;


    //查
    @RequestMapping("/selectVehicle.do")
    public ModelAndView selectVehicle(){
        ModelAndView mv=new ModelAndView();
        List<Vehicle> vehicles=vehiceServiceimpl.selectVehicle();
        mv.addObject("vehiclesList",vehicles);
        mv.setViewName("Vehicle-list");
        return mv;
    }

    //增
    @RequestMapping("/sevaVehicle.do")
    public String sevaVehicle(Vehicle vehicle){
        vehiceServiceimpl.sevaVehicle(vehicle);
        return "redirect:selectVehicle.do";
    }

    //删
    @RequestMapping("/delVehicle.do")
    public String delVehicle(Integer id){
        vehiceServiceimpl.delVehicle(id);
        return "redirect:selectVehicle.do";
    }




}
